<?php
class Model_Bug extends Zend_Db_Table_Abstract
{
	
	protected $_name = 'bugs';
	
	public  function createBug($username,$password,$email)
	{
		$row = $this->createRow();		
		$row->username = $username;
		$row->password = $password;
		$row->email = $email;		
		$row->save();
		return 1;
	}
	
	public function fetchBugs()
	{		
		$select = $this->select();
		return $this->fetchAll();
	}
	public function  updateBug($id, $username, $password, $email){
		$row = $this->find(trim($id))->current();
		if($row){
			$row->username = $username;
			$row->password = $password;
			$row->email = $email;
			$row->save();
			return true;
		}else{
			throw new Zend_Exception("Update failed");
		}
	}
	public function deleteBug($id)
	{
		$row = $this->find(trim($id))->current();
		
		if($row){
			$row->delete();
			return true;
		}
		else{
			throw new Zend_Exception("delete failed");
		}
		
	}	
}